using Game.Main.Model;

namespace Game.Component
{
	public class MoundItem : BaseItem
	{
		private GrowPlantItem plantItem;

		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
		}

		public override bool CanPlaceItem(BaseItem item)
		{
			if (item == null || item.transform.position.y < base.transform.position.y)
			{
				return false;
			}
			return base.CanPlaceItem(item);
		}

		public override bool AttachItem(BaseItem item, DepthType depthType, AttachType attachType, bool updatePosition)
		{
			bool flag = base.AttachItem(item, depthType, attachType, updatePosition);
			if (flag && item != null && item.itemData.scriptType == 147)
			{
				plantItem = (GrowPlantItem)item;
			}
			return flag;
		}

		public override void ReleaseAttachItem(BaseItem item)
		{
			base.ReleaseAttachItem(item);
			plantItem = null;
		}

		public bool CanGrowUp()
		{
			if (plantItem == null || !plantItem.CanGrowUp())
			{
				return false;
			}
			return true;
		}

		public bool GrowUp()
		{
			if (plantItem == null)
			{
				return false;
			}
			BaseItem baseItem = plantItem.GrowUp();
			if (baseItem != null)
			{
				if (baseItem.itemData.scriptType == 147)
				{
					plantItem = (GrowPlantItem)baseItem;
				}
				else
				{
					plantItem = null;
				}
				return true;
			}
			return false;
		}
	}
}
